package com.ego.common.pojo;

import lombok.Data;

import java.util.List;

@Data
public class PageResult<T> {
    private Long total;// 总条数
    private Long totalPage;// 总页数
    private List<T> items;// 当前页数据
    private Integer size = 20;//当前页数量

    public PageResult() {
    }


    public PageResult(Long total, List<T> items) {
        this.total = total;
        this.items = items;
    }

    public PageResult(Long total, Long totalPage, List<T> items) {
        this.total = total;
        this.totalPage = totalPage;
        this.items = items;
    }

    public PageResult(Long total, Long totalPage, List<T> items, Integer size) {
        this.total = total;
        this.totalPage = totalPage;
        this.items = items;
        this.size = size;
    }

    public Long getTotalPage(){
        return this.total%this.size==0?this.total/this.size:(this.total/this.size)+1;
    }
}
